
// importDoc references this import's document
var importDoc = document._currentScript.ownerDocument;

// mainDoc references the main document (the page that's importing us)
var mainDoc = document;


function appendPlayOptionToPage(optionID)
{
	var playOption = $(".playOption[data-game-id=\"" + optionID + "\"]", importDoc);
	
	if(playOption !== undefined && playOption.length == 1)
	{
		var newPlayOption = playOption.clone(true);
		
		//initialisePropertiesWithinElement is only one likely to be needed here, 
		//but might as well be consistent about doing all 3.
		initialiseGenericElementReplacementsWithinElement(newPlayOption[0]);
		initialisePropertiesWithinElement(newPlayOption[0]);
		initialiseInputElementHandlersWithinElement(newPlayOption[0]);
		
		$("#playBox", mainDoc).append(newPlayOption);
		
		return newPlayOption;
	}
	else
	{
		console.error("Cannot find playOption in game specific file!");
		return undefined;
	}
}
